<?php require_once('../../core/import.php');?>
<?php User::Permission('FUNCTION_PERMISSION_LIST'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/checkbox/import.checkbox.js"></script>
    <script type="text/javascript" src="../../scripts/components/zebra_table/import.zebra_table.js"></script>
    <script type="text/javascript" src="scripts/function.list.js"></script>
</head>

<body>
<form id="Form_select" name="Form_select" method="post" action="function.permission.list.php">
    <table width="98.5%" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
         <th width="20%" height="25" align="center" valign="middle">
         <select name="Select_Class" size="1" id="Select_Class">
                        <option value="">--请选择类别--</option> 
                        <?php	
                        $Class=DB::GetRows('select Identifying,Name,Identifying_Parent from `management_user_permission` where Identifying_Parent is null order by RealSort asc');
                                foreach($Class as $ClassID)
                                {
                        ?>
                         <option value="<?php echo $ClassID['Identifying'];?>"> <?php echo $ClassID['Name'];?></option>
                        <?php 
									 $Branch=DB::GetRows('select Identifying,Name from management_user_permission where Identifying_Parent='.$ClassID['Identifying'].' and Branch=1 order by Identifying asc');
									 foreach($Branch as $Branch_Row)
										{
						?>
                         <option value="<?php echo $Branch_Row['Identifying'];?>"> &nbsp;<?php echo '--'.$Branch_Row['Name'];?></option>
                        <?php
										}
                                }
                        ?>
        </select>
        </th>
        <th width="20%" height="25" align="left" valign="middle"><input type="text" name="Keyword" /></th>
        <th width="20%" height="25" align="left" valign="middle">&nbsp;</th>
        <th width="32%" height="25" align="left" valign="middle"><input type="submit" value="搜 索" /></th>
    </tr>
    </thead>
    </table>
</form>
	<table width="98.5%" id="List" border="0" align="center" cellpadding="0" cellspacing="0" class="List">        
    <thead>
    <tr >
        <th width="15%" align="center" valign="middle">&nbsp;模块</th>
        <th width="15%" align="center" valign="middle">&nbsp;功能名称</th>
        <th width="15%" align="center" valign="middle">&nbsp;权限值</th>
        <th width="25%" align="center" valign="middle">&nbsp;链接地址</th>
        <th width="15%" align="center" valign="middle">&nbsp;是否为列表</th>
        <th width="15%" align="center" valign="middle">&nbsp;操作</th>
    </tr>
    </thead>
  <form id="Form1" name="Form1" method="post" >   
    
    <tbody>
    <?php
	  $Keyword=Functions::HttpArgs('Keyword');
	 // $Page=Functions::UrlArgs('page');
	  $Select_Class=Functions::HttpArgs('Select_Class');
	 // exit($Select_Class.'');
	  $Wheres="where Identifying_Parent is not null and Branch is null ";
	  if($Select_Class)
	      {
		  $Wheres=$Wheres." and Identifying_Parent=$Select_Class ";
	 	}
	  if($Keyword)
	      {
		  $Wheres=$Wheres." and Name like '%$Keyword%' ";
	 	}
	  $Orders=$Wheres.' order by ID desc';	
        #获取数据
        $Data=DB::GetData('select Identifying,Name,Role,URL,Identifying_Parent,IsList from `management_user_permission` '.$Orders.' limit ?,14');
	  foreach($Data['Record'] as $Row)
        {
    ?>
    <tr>
        <td height="30" align="center" valign="middle">
          <select name="ClassID_<?php echo $Row['Identifying'];?>" size="1" id="ClassID_<?php echo $Row['Identifying'];?>">
	  		<option value="">--请选择类别--</option> 
			<?php	
			$Class=DB::GetRows('select Identifying,Name from `management_user_permission` where Identifying_Parent is null order by RealSort asc');
				  foreach($Class as $ClassID)
				  {
                  ?>
                   <option value="<?php echo $ClassID['Identifying'];?>" <?php if($ClassID['Identifying']==$Row['Identifying_Parent']){ echo 'selected="selected"' ;}?>> <?php echo $ClassID['Name'];?></option>
                   <?php 
						$Branch=DB::GetRows('select Identifying,Name from management_user_permission where Identifying_Parent='.$ClassID['Identifying'].' and Branch=1 order by Identifying asc');
									 foreach($Branch as $Branch_Row)
										{
						?>
                         <option value="<?php echo $Branch_Row['Identifying'];?>" <?php if($Branch_Row['Identifying']==$Row['Identifying_Parent']){ echo 'selected="selected"' ;}?>> &nbsp;<?php echo '--'.$Branch_Row['Name'];?></option>
				<?php
                                }
                        	}
                ?>
          </select>
        </td>
        <td height="30" align="center" valign="middle">
           <input type="text" id="Name_<?php echo $Row['Identifying'];?>" name="Name_<?php echo $Row['Identifying'];?>"  class="TextboxAdd" value="<?php echo $Row['Name'];?>" />
        </td>
        <td align="center" valign="middle">
           <input type="text" id="Role_<?php echo $Row['Identifying'];?>" name="Role_<?php echo $Row['Identifying'];?>"  class="TextboxAdd" value="<?php echo $Row['Role'];?>" />
        </td>
        <td align="center" valign="middle">
           <input type="text" id="URL_<?php echo $Row['Identifying'];?>" name="URL_<?php echo $Row['Identifying'];?>" size="50" class="TextboxAdd" value="<?php echo $Row['URL'];?>" />
        </td>
        <td height="25" align="center" valign="middle">
            <input type="radio" name="IsList_<?php echo $Row['Identifying'];?>" id="IsList_<?php echo $Row['Identifying'];?>" value="1" <?php if($Row['IsList']==1){ echo 'checked' ;}?>/> 是&nbsp;
	  	<input type="radio" name="IsList_<?php echo $Row['Identifying'];?>" id="IsList_<?php echo $Row['Identifying'];?>" value="0" <?php if($Row['IsList']==0){ echo 'checked' ;}?>/> 否 
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	if(Functions::HttpArgs('page')){
				$Page=Functions::HttpArgs('page');
			}else{
				$Page=1;
			}
			if(!$Select_Class){	
				$Select_Class=0;
			}
		?>
            <a href="javascript:Edit(<?php echo $Row['Identifying'].','.$Page.','.$Select_Class;?>);">修改</a>
            <a href="javascript:mconfirm_delete('function.permission.action.delete.php?id=<?php echo $Row['Identifying'];?>');">删除</a>
        </td>
    </tr>
    <?php
        }
    ?>
    
    </tbody> 
    <tfoot>
    <tr>
    	 <td height="25" colspan="6" align="left" valign="middle">
    		<table width="98.5%" id="List" align="center" border="0" cellpadding="0" cellspacing="0" class="List">
   		  <tr bgcolor="#CCCCCC" height="30">
                    <td align="center" width="15%">
       			<font> &nbsp;模块：</font> 
                        <select name="ClassID" size="1" id="ClassID">
                        <option value="">--请选择类别--</option> 
                        <?php	
                        $Class=DB::GetRows('select Identifying,Name,Identifying_Parent from `management_user_permission` where Identifying_Parent is null order by RealSort asc');
                                foreach($Class as $ClassID)
                                {
                        ?>
                         <option value="<?php echo $ClassID['Identifying'];?>"> <?php echo $ClassID['Name'];?></option>
                        <?php 
									 $Branch=DB::GetRows('select Identifying,Name from management_user_permission where Identifying_Parent='.$ClassID['Identifying'].' and Branch=1 order by Identifying asc');
									 foreach($Branch as $Branch_Row)
										{
						?>
                         <option value="<?php echo $Branch_Row['Identifying'];?>"> &nbsp;<?php echo '--'.$Branch_Row['Name'];?></option>
                        <?php
										}
                                }
                        ?>
                        </select>
     			  </td> 
     			  <td align="center" width="20%">
       			<font>&nbsp;功能名称：</font> <input type="text" id="Name_Add" name="Name_Add"  class="TextboxAdd" />
     			  </td> 
                    <td align="center" width="20%">
      		 	<font> &nbsp;权限值：</font> <input type="text" id="Role_Add" name="Role_Add"  class="TextboxAdd" />
     			  </td>
     			  <td align="center" width="20%">
      		 	<font> &nbsp;链接地址：</font> <input type="text" id="URL_Add" name="URL_Add" class="TextboxAdd" />
     			  </td>
                    <td align="center" width="15%">
      		 	<font> &nbsp;列表：</font> 
                         <input type="radio" name="IsList_Add" id="IsList_Add" value="1" /> 是&nbsp;
	  		 	 <input type="radio" name="IsList_Add" id="IsList_Add" value="0" checked/> 否 
     			  </td>
     			  <td align="left" width="10%">
       			<span id="LinkAdd" class="Cursor_Pointer"><font size="3">添加</font></span>
     			  </td>
  		 </tr>  
   		</table>
    	</td>
    </tr>
    </tfoot>   
    <tfoot>
    <tr>
        <td height="25" colspan="6" align="center" valign="middle">
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="55%" align="left">
                <?php
                    PagerFactory::Create('Simple')->Display($Data,array
			  (
			  		'Parameters'=>array(
					'Keyword'=>$Keyword,
					'Select_Class'=>$Select_Class
				)
				
			  ));
                ?>
                </td>
            </tr>
            </table>    
         </td>
	</tr>
    </tfoot>
    </form>
    </table> 
  


</body>
</html>